package algo.stack.impl;

import com.fay.algo.stack.impl.ArrayStack;
import com.fay.algo.stack.impl.LinkedListBasedStack;
import com.fay.algo.stack.impl.Stack;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/4/27 10:34
 * @Version 1.0
 */
public class StackTest {
    public static void main(String[] args) {
        checkArrayStack();
        checkLinkedListStack();
    }

    private static void checkLinkedListStack() {
        LinkedListBasedStack<Integer> stack = new LinkedListBasedStack<>();
        for (int i = 0; i < 5; i++) {
            stack.push(i);
            System.out.println(stack);
        }
        stack.pop();
        System.out.println(stack);
    }

    private static void checkArrayStack() {
        Stack<Integer> stack = new ArrayStack<>();
        for (int i = 0; i < 5; i++) {
            stack.push(i);
            System.out.println(stack);
        }
        stack.pop();
        System.out.println(stack);
        stack.peek();
        System.out.println(stack.isEmpty());
        System.out.println(stack.getSize());
    }
}
